package com.util.fileUpload;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.io.FilenameUtils;

import com.util.abstractAction.AbstractAction;


public class UploadFile extends AbstractAction {

    private static final long serialVersionUID = -600441846925455090L;

    private File file;

    private String path;

    private String formate;

    private int[] height;

    private int[] width;

    private String basePath;

    private String protypeFileName;

    private String localPath;

    public UploadFile() {
    }

    public UploadFile(File file, String path, String protypeFileName, HttpServletRequest request) {
        this(file, path, protypeFileName, 0, 0, request);
    }

    /**
     * @param width
     */
    @SuppressWarnings("deprecation")
    public UploadFile(File file, String path, String protypeFileName, int height, int width,
            HttpServletRequest request) {
        this.basePath = request.getRealPath("/") + "resource/";
        this.path = uploadBasePath + path;
        this.formate = FilenameUtils.getExtension(protypeFileName);
        this.setFile(file);
        this.setProtypeFileName(protypeFileName);
        this.setHeight(new int[] { height });
        this.setWidth(new int[] { width });
    }
    @SuppressWarnings("deprecation")
    public UploadFile(File file, String path, String protypeFileName, int[] height, int[] width,
            HttpServletRequest request) {
        this.basePath = request.getRealPath("/") + "resource/";
        this.path = uploadBasePath + path;
        this.formate = FilenameUtils.getExtension(protypeFileName);
        this.setFile(file);
        this.setProtypeFileName(protypeFileName);
        this.setHeight(height);
        this.setWidth(width);
    }

    public String getProtypeFileName() {
        return protypeFileName;
    }

    public void setProtypeFileName(String protypeFileName) {
        this.protypeFileName = protypeFileName;
    }

    public String getBasePath() {
        return basePath;
    }

    public int[] getHeight() {
        return height;
    }

    public void setHeight(int[] height) {
        this.height = height;
    }

    public int[] getWidth() {
        return width;
    }

    public void setWidth(int[] width) {
        this.width = width;
    }

    public String getFormate() {

        return formate;
    }

    @Deprecated
    public void setFormate(String formate) {
        this.formate = formate;
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }

    public String getLocalPath() {
        return localPath;
    }

    public void setLocalPath(String localPath) {
        this.localPath = localPath;
    }

    private final static String uploadBasePath = "upload/";

}
